package com.goods.controller.business;

import com.goods.business.service.InStockService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockDetailVO;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.business.ProductVO;
import com.goods.common.vo.business.SupplierVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**********************
 *
 *@Author 闫星忠
 *@Time 2021/12/16  15:58
 *
 */
@Api(tags = "业务模块-物资入库相关接口")
@RestController
@RequestMapping("business/inStock")
public class InStockController {

    @Autowired
    private InStockService inStockService;

    @ApiOperation(value = "分页展示物资入库信息列表")
    @GetMapping("/findInStockList")
    public ResponseBean<PageVO<InStockVO>> findInStockList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize") Integer pageSize,
                                                           InStockVO inStockVO) {
        PageVO<InStockVO> inStockList = inStockService.findInStockList(pageNum, pageSize,inStockVO);
        return ResponseBean.success(inStockList);
    }

    @ApiOperation(value = "点击明细按钮显示明细")
    @GetMapping("/detail/{id}")
    public ResponseBean<InStockDetailVO> detail(@PathVariable Integer id,
                                                @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
        InStockDetailVO inStockDetailVO =inStockService.detail(id,pageNum);
        return ResponseBean.success(inStockDetailVO);
    }

    @ApiOperation(value = "已入库记录移入回收站")
    @PutMapping("/remove/{id}")
    public ResponseBean remove(@PathVariable Long id){
        inStockService.remove(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "移出回收站到已入库")
    @PutMapping ("/back/{id}")
    public ResponseBean back(@PathVariable Long id){
        inStockService.back(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "从回收站删除入库记录")
    @DeleteMapping("/delete/{id}")
    public ResponseBean update(@PathVariable Long id){
        inStockService.delete(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "商品入库")
    @PostMapping("/addIntoStock")
    public ResponseBean addIntoStock(@RequestBody InStockVO inStockVO){
        inStockService.addIntoStock(inStockVO);

        return ResponseBean.success();
    }

    @ApiOperation(value = "待审核转到正常")
    @PutMapping ("/publish/{id}")
    public ResponseBean publish(@PathVariable Long id){
        inStockService.publish(id);
        return ResponseBean.success();
    }


}
